<template>
    <div class="login-page">
        <div class="content">
            <div class="ipt-box">
                <span>账户:</span>
                <input type="text" v-model="accoutVal" />
            </div>
            <div class="ipt-box">
                <span>密码:</span>
                <input type="password" v-model="pwdVal" />
            </div>
            <van-button type="primary" @click="loginFn">登录</van-button>
        </div>
    </div>
</template>

<script>
import { LoginApi } from '@/request/api';
export default {
    data() {
        return {
            accoutVal: '17822221111',
            pwdVal: null, //不检验密码
        };
    },
    created() {},
    methods: {
        loginFn() {
            LoginApi({
                username: this.accoutVal,
                password: this.pwdVal,
            })
                .then((res) => {
                    if (res.errCode === 0) {
                        localStorage.setItem('token', res.data);
                        this.$router.push('/index/func');
                    }
                })
                .catch(() => {
                    this.$toast.fail('用户名或密码错误');
                });
        },
    },
    components: {},
};
</script>

<style lang="less" scoped>
.login-page {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    min-height: 100vh;
    box-sizing: border-box;
    background: url('../assets/images/login/login_bg.jpg') no-repeat top center;
    background-size: 100% 100%;
    .content {
        width: 100%;
        position: absolute;
        bottom: 2rem;
        display: flex;
        flex-direction: column;
        align-items: center;
        .ipt-box {
            width: 4.34rem;
            height: 0.7rem;
            margin-bottom: 0.28rem;
            font-weight: bold;
            border-radius: 0.7rem;
            border: 0.02rem solid #000;
            background-color: #ffcc33;
            overflow: hidden;
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0 0.44rem;
            box-sizing: border-box;
            span {
                display: block;
            }
            input {
                box-sizing: border-box;
                border: none;
                outline: none;
                background: none;
                width: 75%;
                height: 100%;
            }
        }
        .van-button {
            margin-top: 1rem;
            width: 3.21rem;
            height: 0.93rem;
            box-sizing: border-box;
            border: 0.04rem solid #000;
            background-color: #4366fe;
            border-radius: 0.93rem;
        }
    }
}
</style>
